home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 6⁄1⁄90 / 0136-Re C++ string initia-Jun90 < prev    next >
Encoding:
Text File  |  1990-06-01  |  1.1 KB  |  36 lines  |  [TEXT/GEOL]

  1. Item    9465931                         1-June-90        10:28PDT
  2.  
  3. From:   D0532                           Aidea Systems, Don Park,PRT
  4.  
  5. To:     CPLUS.DEV$                      C++ Interest List--Developers
  6.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  7.  
  8. Sub:    Re: C++ string initialization
  9.  
  10. The problem seems to be caused by the way CFront translates variable
  11. initialization statement into an assignment statement.
  12.  
  13. Following C++ code:
  14.  
  15.     typedef char stringType[32];
  16.     stringType myOtherString = "Hello2";
  17.  
  18. is tranlated into:
  19.  
  20.     typedef char stringType[32];
  21.     stringType myOtherString;       << Initialization removed!!!
  22.     myOtherString = "Hello2";       << Replaced with assignment!!!
  23.  
  24. which is not acceptable to C compiler.
  25.  
  26. I am not sure what the story behind this is but there seems to be a
  27. work-around.  Just put the initialization string within a block.  i.e.
  28.  
  29.     stringType myOtherString = { "Hello2" };
  30.  
  31. This seems to prevent CFront from breaking the statement up and is acceptable
  32. to C compiler as well.
  33.  
  34. Don Park
  35.  
  36.